//
//  ZYXCourseOneCell.m
//  RuiBeiKang
//
//  Created by iOS开发1 on 2019/1/15.
//  Copyright © 2019年 JW. All rights reserved.
//

#import "ZYXCourseOneCell.h"

@implementation ZYXCourseOneCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    

    

}
-(void)setModel:(ZYXCourseDetModel *)model{
    _model = model;
    self.titleLabel.text = model.title;
    self.teacherName.text = [NSString stringWithFormat:@"讲师%@",model.teacher];
    self.detLabel.text = [NSString stringWithFormat:@"讲师简介：%@",model.teacherdescribe];
    if (model.chapter.length >0) {
        NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"共%@章  %@已观看",model.chapter,model.attention]];
        NSRange range1 = [[str1 string] rangeOfString:model.chapter];
        [str1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"1cca62"] range:range1];
        NSRange range2 = [[str1 string] rangeOfString:model.attention];
        [str1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"1cca62"] range:range2];
        self.countLabel.attributedText = str1;
    }
    if ([model.is_collect isEqualToString:@"2"]) {
        self.collectionBtn.selected = YES;
            [self.collectionBtn setTitle:[NSString stringWithFormat:@"%@人已收藏",model.collection] forState:UIControlStateSelected];
    }else{
        self.collectionBtn.selected = NO;
            [self.collectionBtn setTitle:[NSString stringWithFormat:@"%@人已收藏",model.collection] forState:UIControlStateNormal];
    }

//    NSForegroundColorAttributeName:[UIColor redColor]
    NSString * htmlString = model.describtion;
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];
    self.contentLabel.attributedText = attrStr;
}


@end
